#include "d3dApp.h"

namespace D3D10
{
class InitDirect3DApp : public D3DApp
{
	public:
		InitDirect3DApp(const HINSTANCE handleInstance);
		~InitDirect3DApp();

		void initApp();
		void onResize();
		void updateScene(const float deltaTime);
		void drawScene(); 
	};

	InitDirect3DApp::InitDirect3DApp(const HINSTANCE handleInstance)
	: D3DApp(handleInstance) 
	{
	}

	InitDirect3DApp::~InitDirect3DApp()
	{
		if (md3dDevice)
			md3dDevice->ClearState();
	}

	void InitDirect3DApp::initApp()
	{
		D3DApp::initApp();
	}

	void InitDirect3DApp::onResize()
	{
		D3DApp::onResize();
	}

	void InitDirect3DApp::updateScene(const float deltaTime)
	{
		D3DApp::updateScene(deltaTime);
	}

	void InitDirect3DApp::drawScene()
	{
		D3DApp::drawScene();

		// We specify DT_NOCLIP, so we do not care about width/height of the rect.
		RECT R = {5, 5, 0, 0};
		mFont->DrawText(0, mFrameStats.c_str(), -1, &R, DT_NOCLIP, D3D10Utils::BLACK);

		mSwapChain->Present(0, 0);
	}
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd)
{
	// Enable run-time memory check for debug builds.
#if defined(DEBUG) | defined(_DEBUG)
	_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif

	D3D10::InitDirect3DApp theApp(hInstance);
	
	theApp.initApp();

	return theApp.run();
}
